package ms.unicorn.erml.helper;

import java.util.Map;

import ms.unicorn.Element;
import ms.unicorn.erml.decorators.DependencyDecoration;
import ms.unicorn.erml.locators.RotatableObjectLocator;
import ms.unicorn.modellanguage.LanguageRelationEditHelperAdvice;

import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.ConnectionLocator;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;

public class DependencyEditHelperAdvice extends
		LanguageRelationEditHelperAdvice {

	public DependencyEditHelperAdvice() {
		
	}

	@Override
	public Map<String, IFigure> createFigures(EditPart context,
			Element element, EditPart elementEditPart) {
		Map<String, IFigure> figures = super.createFigures(context, element, elementEditPart);
		IFigure connection = figures.get(FIGURE_CONNECTION);
		// create decorator
		if (connection instanceof PolylineConnectionEx) {
		
			DependencyDecoration decoration = new DependencyDecoration("De");
			((PolylineConnectionEx) connection).setTargetDecoration(decoration,
					new RotatableObjectLocator((Connection)connection, ConnectionLocator.MIDDLE));
		}
		return figures;
	}
}
